package com.zyx.camunda.config.web;

import com.zyx.camunda.helpers.context.UserInfoContext;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zyx
 * @since 2023/9/21 09:59
 */
public class UserHandlerInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        UserInfoContext.remove();
        // 这里可以写自己的逻辑
        UserInfoContext.setUserID("101");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        UserInfoContext.remove();
    }

}
